import $API from '@/api/services'

const graphic = {
  state: {
    graphicItem: null
  },
  mutations: {
    SAVE_CURRENT_GRAPHIC: (state, data) => {
      state.graphicItem = data
    }
  },
  actions: {
    fetchGraphicData({ commit }, id) {
      $API('getGraphicDescript', [id]).then(res => {
        if(res.data) {
          commit('SAVE_CURRENT_GRAPHIC', res.data)
          this._vm.$vgo.emit('modal:graphic', res.data)
        }
      })
    }
  }
}

export default graphic
